package terra.network.packet.server;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;

public class TimeInfo extends Packet {

	public static final byte DAY = 0;
	public static final byte DAWN = 1;
	public static final byte NIGHT = 2;
	public static final byte DUSK = 3;
	
	public byte time;
	public float lightIntense;	
	
	public TimeInfo(byte current, float lightIntense2) {
		time = current;
		lightIntense=lightIntense2;
	}

	public TimeInfo() {
	}

	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());
		buf.writeByte(time);
		buf.writeFloat(lightIntense);
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		time = buf.readByte();
		lightIntense = buf.readFloat();
		return this;
	}

	@Override
	public int getLength() {
		return 6;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 12;
	}
	
	@Override
	public byte getPriority() {
		return PRIOR_NORMAL;
	}

}
